package com.wc.alorithm_luogu.P2392;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.StreamTokenizer;
import java.util.Arrays;

/**
 * @Author congge
 * @Date 2023/9/24 19:10
 * <p>
 * kkksc03考前临时抱佛脚
 * https://www.luogu.com.cn/problem/P2392
 * @description
 */
public class Main {
    static Input scan = new Input();

    public static void main(String[] args) {

        int s1 = scan.nextInt();
        int s2 = scan.nextInt();
        int s3 = scan.nextInt();
        int s4 = scan.nextInt();

        int[] s1Array = new int[s1];
        int[] s2Array = new int[s2];
        int[] s3Array = new int[s3];
        int[] s4Array = new int[s4];

        Main main = new Main();
        main.inputArray(s1Array);
        main.inputArray(s2Array);
        main.inputArray(s3Array);
        main.inputArray(s4Array);

        int ans = 0;
        ans += main.sumArray(s1Array);
        ans += main.sumArray(s2Array);
        ans += main.sumArray(s3Array);
        ans += main.sumArray(s4Array);

        int ans2 = 0;

        System.out.println(ans);
    }

    public int sumArray(int[] array) {
        if (array.length == 1) {
            return array[0];
        }

        Arrays.sort(array);
        int ans = 0;
        int idx = array.length - 1;

        int brain = 0;
        while (idx >= 0) {
            if (array[idx] >= brain) {
                ans += brain;
                brain = array[idx] - brain;
            } else {
                brain -= array[idx];
                ans += array[idx];
            }
            array[idx] = 0;
            idx--;
        }

        if (brain != 0) {
            ans += brain;
        }

        return ans;
    }

    public int sumArray2(int[] array) {
        if (array.length == 1) {
            return array[0];
        }

        Arrays.sort(array);
        int ans = 0;
        int idx = array.length - 1;

        while (array[idx] != 0 && array[idx - 1] != 0) {
            ans += array[idx - 1];
            array[idx - 1] = 0;
            array[idx] -= array[idx - 1];
            Arrays.sort(array);
        }

        if (array[idx] != 0) {
            ans += array[idx];
        }
        return ans;
    }

    public void inputArray(int[] array) {
        for (int i = 0; i < array.length; i++) {
            array[i] = scan.nextInt();
        }
    }

    static class Input {
        StreamTokenizer in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));

        public int nextInt() {
            try {
                in.nextToken();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return (int) in.nval;
        }
    }
}
